package com.etxxy.common.webservice;

import org.codehaus.xfire.MessageContext;
import org.codehaus.xfire.handler.AbstractHandler;
import org.jdom.Element;

/**
 * @category 客户端认证
 * 
 * @author yiz
 * @date 2016年5月11日 下午1:45:57
 * @version 1.0.0 
 * @copyright pycredit.cn 
 */
public class ClientAuthHandler extends AbstractHandler {

	private String username;

	private String password;

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public ClientAuthHandler() {
	}

	public ClientAuthHandler(String username, String password) {
		this.username = username;
		this.password = password;
	}

	@Override
	public void invoke(MessageContext context) throws Exception {
		Element element = new Element("header");
		context.getOutMessage().setHeader(element);
		Element authEle = new Element("AuthenticationToken");

		Element usernameEle = new Element("username");
		usernameEle.addContent(username);

		Element passwordEle = new Element("password");
		passwordEle.addContent(password);

		authEle.addContent(usernameEle);
		authEle.addContent(passwordEle);

		element.addContent(authEle);
	}

}
